package service;

import bean.Conurses;
import bean.Scores;
import bean.XuanKe;
import dao.ConursesDaoImpl;
import dao.IConursesDao;
import dao.ISconresDao;
import dao.IXuanKeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LgoinImpl implements ILgoin{
    @Autowired
    ISconresDao scoresDao;
    @Autowired
    IConursesDao iConursesDao;
    @Autowired
    IXuanKeDao xuanKeDao;
    @Override
    public Boolean login(String number, String password) {
        if(number.equals("11015")&&password.equals("654321")){
            System.out.println("教师登录成功");
            System.out.println("查询所有成绩记录");
            ISconresDao.selectAll();
            for (Scores scores : ISconresDao.selectAll()) {
                System.out.println(scores);
            }
            System.out.println("更新20220102001的数学成绩");
            ISconresDao.updateScores(100, "20220102001");
            ISconresDao.getScores("20220102001");
            System.out.println(ISconresDao.getScores("20220102001"));




        } else if (number.equals("20220102001")&&password.equals("123456")) {
            System.out.println("学生登录成功");
            System.out.println("查询20220102001的成绩记录");
            Scores scores = ISconresDao.getScores("20220102001");
            System.out.println(scores);
            System.out.println("查询待选课记录");
            IConursesDao.selectAll();
            for (Conurses conurses : IConursesDao.selectAll()) {
                System.out.println(conurses);
            }
            System.out.println("更新的选课记录");
            iConursesDao.updateConurses(1);
            xuanKeDao.updateXuanke("20220102001",1);
            System.out.println("查询20220102001的选课记录");
            XuanKe xuanke = xuanKeDao.getXuanKe("20220102001");
            System.out.println(xuanke);



        }
        return true;
    }
}
